/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.com.ugto.caadi.asistencias.util;

import com.toedter.components.JSpinField;
import java.awt.Component;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JViewport;

/**
 *
 * @author Maestria
 */
public class GUIUtil {
    
    public static void limpiar(JComponent contenedor) {
        Component[] componentes = contenedor.getComponents();
        for (Component component : componentes) {
            if (component instanceof JTextField) {
                ((JTextField) component).setText("");
            } else if (component instanceof JTextPane) {
                ((JTextPane) component).setText("");
            } else if (component instanceof JTextArea) {
                ((JTextArea) component).setText("");
            } else if (component instanceof JComboBox) {
                ((JComboBox) component).setSelectedIndex(0);
            } else if (component instanceof JScrollPane) {
                limpiar((JScrollPane) component);
            } else if (component instanceof JViewport) {
                limpiar((JViewport) component);
            } else if (component instanceof JSpinField) {
                ((JSpinField) component).setValue(0);
            }
        }
    }
}
